package studio.banner.reference.controller;

import org.springframework.beans.factory.annotation.Autowired;
import studio.banner.reference.mapper.DocumentMapper;
import studio.banner.reference.service.AggregateService;
import studio.banner.reference.service.DocumentService;
import studio.banner.reference.service.UserInfoService;
import studio.banner.reference.service.UserLoginService;

import javax.servlet.http.HttpSession;

/**
 * @ClassName BaseController
 * @Deacription 为Controller创建公用的Service层及Dao层对象
 * @Author Baofeng.Wu
 * @Date 2019/10/24 15:21
 **/
public class BaseController {
    @Autowired
    protected UserInfoService userInfoService;
    @Autowired
    protected UserLoginService userLoginService;
    @Autowired
    protected DocumentService documentService;
    @Autowired
    protected AggregateService aggregateService;
    @Autowired
    protected DocumentMapper documentMapper;


    /**
     * 从Session中获取用户Id[userId]
     *
     * @param session
     * @return
     */
    public Integer getUserIdBySession(HttpSession session) {
        //用户Id在Session中的变量名
        String userIdAttribute = "userId";
        Integer userId = (Integer)session.getAttribute(userIdAttribute);
        return userId;
    }
}
